/**
 * Created by forcht on 2018/5/19.
 */
public class Solution {

    public int maxProfit(int[] prices) {
        int sum=0;
        for(int i=0;i<prices.length-1;i++){
            int t=prices[i+1]-prices[i];
            if (t>0)sum+=t;
        }
        return sum;
    }

    public static void main(String[] args) {
        Solution solution=new Solution();
        int[] a={3,4,5,7};
        System.out.println(solution.maxProfit(a));
    }
}
